package com.zhny.sensor.dao;

import com.zhny.sensor.entity.BarcodeMachineUser;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

/**
 * @Auther: zhy
 * @Date: 2019/11/20
 * @Description: 脚标机用户信息管理
 */
public interface BarcodeMachineUserRepository extends JpaRepository<BarcodeMachineUser,String> {

    BarcodeMachineUser findByBarcodeMachineId(String machineId);

    @Query("select u.isUpdate from BarcodeMachineUser u where u.barcodeMachineId = ?1")
    String findIsupdateByBarcodeMachineId(String machineId);

    @Modifying
    @Query("update BarcodeMachineUser u set u.isUpdate = '0' where u.barcodeMachineId = ?1")
    int setIsupdateByBarcodeMachineId(String machineId);

    //minxin
    @Query("select u.timeVersion from BarcodeMachineUser u where u.barcodeMachineId = ?1")
    String findTimeVersionByBarcodeMachineId(String machineId);

    //minxin
    @Modifying
    @Query("update BarcodeMachineUser u set u.timeVersion = ?1 where u.barcodeMachineId = ?2")
    int setTimeVersionByBarcodeMachineId(String timeVersion, String machineId);

}
